package com.hy.kafka.service;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

@Service
public class KafkaService {
    @Autowired
    private KafkaTemplate kafkaTemplate;

    /**
     * 推送信息到消息队列
     * @param jsonObject
     */
    public void sendMsg(JSONObject jsonObject){
        kafkaTemplate.send("TOPICNAME", "hy", jsonObject.toJSONString());
    }
}
